const http = require('http')
const server = http.createServer()
server.on('request', (req, res) => {
    const str = `你的url地址是 ${req.url},你的method是${req.method}`
    // 需设置响应头的数据格式为setHeader('Content-Type', 'text/html; charset=utf-8') 就可解决中文乱码的问题
    // 注意setHeader里参数为两个 'Content-Type', 'text/html; charset=utf-8'
    res.setHeader('Content-Type', 'text/html; charset=utf-8')
    res.end(str)
})
server.listen(80, () => {
    console.log('Server runing at http://127.0.0.1');
})

